# @Author ZhangGJ
# @Date 2021/11/23 17:55

import cv2.cv2 as cv2
import numpy as np


def dark_image():
    width = 200
    height = 100
    img = np.zeros((height, width), np.uint8)
    cv2.imshow('img', img)
    cv2.waitKey()
    cv2.destroyAllWindows()


def white_image():
    width = 200
    height = 100
    img = np.ones((height, width), np.uint8) * 255
    cv2.imshow('img', img)
    cv2.waitKey()
    cv2.destroyAllWindows()


def draw_image():
    width = 200
    height = 100
    img = np.zeros((height, width), np.uint8)
    img[25:75, 50:100] = 255
    cv2.imshow('img', img)
    cv2.waitKey()
    cv2.destroyAllWindows()


def draw_image2():
    width = 200
    height = 100
    img = np.zeros((height, width), np.uint8)
    for i in range(0, width, 40):
        img[:, i:i + 20] = 255
    cv2.imshow('img', img)
    cv2.waitKey()
    cv2.destroyAllWindows()


def draw_color_image():
    width = 200
    height = 100
    img = np.zeros((height, width, 3), np.uint8)
    blue = img.copy()
    blue[:, :, 0] = 255
    green = img.copy()
    green[:, :, 1] = 255
    red = img.copy()
    red[:, :, 2] = 255
    cv2.imshow('blue', blue)
    cv2.imshow('green', green)
    cv2.imshow('red', red)
    cv2.waitKey()
    cv2.destroyAllWindows()


def random_image():
    width = 200
    height = 100
    img = np.random.randint(256, size=(height, width), dtype=np.uint8)
    cv2.imshow('img', img)
    cv2.waitKey()
    cv2.destroyAllWindows()


def random_image2():
    width = 200
    height = 100
    img = np.random.randint(256, size=(height, width, 3), dtype=np.uint8)
    cv2.imshow('img', img)
    cv2.waitKey()
    cv2.destroyAllWindows()


# 水平拼接
def horizontal_stitch():
    a = np.array([1, 2, 3])
    b = np.array([4, 5, 6])
    c = np.array([7, 8, 9])
    result = np.hstack((a, b, c))
    print(result)


# 垂直拼接
def vertical_stitch():
    a = np.array([1, 2, 3])
    b = np.array([4, 5, 6])
    c = np.array([7, 8, 9])
    result = np.vstack((a, b, c))
    print(result)


# 图片拼接
def apply():
    img = cv2.imread('../images/flower.jpg')
    img_h = np.hstack((img, img))
    img_v = np.vstack((img, img))
    cv2.imshow('img_h', img_h)
    cv2.imshow('img_v', img_v)
    cv2.waitKey()
    cv2.destroyAllWindows()


if __name__ == '__main__':
    apply()
